home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Tools (InfoMagic)
/
Internet Tools.iso
/
dos_win
/
winsock
/
hacklist
/
94-04.Z
/
94-04
/
000000_alun@internet.wst.com_Thu Apr 3 02:49:00 1994.msg
next >
Wrap
Internet Message Format
|
1994-04-30
|
5KB
Received: from internet.wst.com.wst.com ([198.64.82.8]) by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
id AA12995; Thu, 31 Mar 1994 09:47:42 -0500
Received: by internet.wst.com.wst.com (4.1/SMI-4.1)
id AA00735; Thu, 31 Mar 94 08:49:01 CST
From: alun@internet.wst.com (Alun Jones)
Message-Id: <9403311449.AA00735@internet.wst.com.wst.com>
Subject: Re: What does send() returning 0 mean ? revisited
To: paul@atlas.abccomp.oz.au
Date: Thu, 31 Mar 94 8:49:00 CST
Cc: winsock-hackers@sunsite.unc.edu
In-Reply-To: <9403310450.AA25514@atlas>; from "paul@atlas.abccomp.oz.au" at Mar 31, 94 8:54 am
X-Mailer: ELM [version 2.3 PL11]
> I'd like to conduct a straw-poll please, on the expected behaviour
> of calling send() with a zero length - this seems to be one
> case that different stacks handle quite differently, and there is currently
> no guidance in the specification.
I would ask what the expected use of a send() call with zero length
would be - is it just a device so that a programmer doesn't have to
surround his send() calls with an if statement to check that the
number of bytes is not zero? If this is the only advantage of this
approach, then I would advocate not allowing 0 as a number of bytes to
send.
> My thoughts are that this is a perfectly valid, though not
> particularly useful, thing to do, and that this is the only time it
> is valid for send() to return 0 - which indicates success, 'cause the
> number of bytes able to be written == number of bytes requested.
> Other stacks seem to call this an error, and Trumpet Winsock returns
> SOCKET_ERROR with error code WSAEINVAL (Invalid Argument) [ although the
> Error Codes section for send() indicates WSAEINVAL means "The socket
> has not been bound with bind()"]
Being strictly pedantic, the documentation says that (on a
non-blocking SOCK_STREAM socket, at least) the return value will be
between 1 and the number of bytes requested, or the error condition.
"Between" is one issue here - mathematically, I guess this could mean
"between 1 and 0" if the number of bytes requested is 0, but a more
English oriented reading implies that the number of bytes requested
would be more than (or equal to) 1.
I believe that returning 0 if the number of bytes requested is greater
than 0 is a BAD THING, since that means that no data could be sent, or
stored for sending, which really means WSAEWOULDBLOCK (on non-blocking
sockets). Obviously, a blocking socket won't return anything until
all of the bytes have been sent, or an error has occurred, so a
blocking socket should either return an error condition, or the number
you requested. (Note that if you want to send a two/more part message
out on a blocking port, and want to use the number returned from
send() to determine where any error occurred, and which messages made
it through, you should probably be looking at calling send() once for
each message instead, or going to non-blocking sockets).
The only use I can see for _passing_ 0 bytes in to the send() function
is to tell if all previous (non-blocking) sends have been sent through
the transport layer, by setting the socket to blocking, and sending 0
bytes. A stack might then decide to block until all buffered output
has been sent. This is not described in the documentation, however,
and would require either stack dependency (a BAD THING), or a new
standard (a GOOD THING). However, the approach of winsock seems to be
that the application developer should not need to know when data has
been sent through the transport, so even this would be a rather
dubious functionality to ask for.
> Comments from others, both stack developers and application
> developers, please ....
As background, I am an application developer - I wrote cooksock and
wftpd. Wftpd seems to break quite a few stacks, since I tend to be
somewhat pedantic about the things I expect from compliant stacks.
I'm hoping that winsock stack developers have as open minded an
approach to making their stacks more usable to winsock application
developers, as they had to implementing the spec in the first place.
I know that FTP Software are continually improving their software to
make it more useful to other winsock developers, and I'd like to see
similar approaches from the other winsock stack developers.
My other pet(ty) gripe is that there is (apparently) no freely
available documentation about differences between various
implementations of winsock. When a user calls me and says "I can't
get your program working on stack x", it would be nice to be able to
search through a list of that vendor's differences from the winsock
spec, and from other vendors - things like DNS compatibility, what
kind of error values are returned, which functions aren't yet written,
what assumptions had to be made that weren't covered in the spec -
that sort of thing. I would suggest that a "docs" area on sunsite
might be a good place to store such information if it existed, but
since sunsite isn't my site, I can't expect that such a thing would
happen. I'd offer this site, but we have a 14400 baud modem
connecting us to the rest of the world, so I don't think that would be
a great idea!
Alun.